package com.mike.mybatis;

import java.util.ArrayList;
import java.util.List;

public abstract class AbstractSQL<T> {
    private AbstractSQL.SQLStatement sql = new AbstractSQL.SQLStatement();
    public T FROM(String table) {
        this.sql().tables().add(table);
        return this.getSelf();
    }

    public abstract T getSelf();

    private AbstractSQL.SQLStatement sql(){
        return this.sql;
    }

    private static class SQLStatement extends AbstractSQL.SQLBase {
        public SQLStatement() {
            super();
        }
    }

    private static class SQLBase {
        private List<String> tables;

        private SQLBase(){
            tables = new ArrayList<>();
        }

        protected List<String> tables() {
            if (this.tables == null) {
                this.tables = new ArrayList();
            }

            return this.tables;
        }
    }
}
